package Week2.J0426;

// 无法使用贪心算法！
// 无法使用一次函数！
// 只能枚举

// 数值较大，超出int范围，故用long

import java.util.Scanner;

public class 游游的水果大礼包_xv {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextInt();
        long m = scanner.nextInt();
        long a = scanner.nextInt();
        long b = scanner.nextInt();
        long sum = 0;
        // 2n + m = a;
        // m + 2n = b;

        for (long x = 0; x < Math.min(n / 2, m); x++) {
            long y = Math.min((m - x) / 2, n - 2 * x);
            sum = Math.max(sum, a * x + b * y);
        }
        System.out.println(sum);
    }
}
